<template>
  <div class="Add">
    <p>
      标题：
      <input type="text" />
    </p>
    <p>
      作者：
      <input type="text" />
    </p>
    <p>
      <button @click="add">添加</button>
    </p>
  </div>
</template>
<script>
export default {
  data() {
    return {
      username: "",
      author: ""
    };
  },
  methods: {
    add() {
      if (this.username == "" || this.author == "") {
        return alert("输入不合格");
      }
      var obj = { username: this.username, author: this.author };
      this.$emit("add");
    }
  }
};
</script>